<style src="./style.css" scoped></style>

<template>
  <osc-navpage
    class="personal-root"
    title="餐饮连锁供应链"
    height="100"
    titleColor="#000"
    backgroundColor="#eff3f2"
    leftItemSrc="https://olwr1lamu.qnssl.com/ViewGallery.png"
    @naviBarLeftItemClick="naviBarLeftItemClick">
      <div class="root">
        <!-- 背景图 -->
        <image class="img-top" src="https://olwr1lamu.qnssl.com/%E8%83%8C%E6%99%AF2.jpg"></image>

        
        <div class="div-content">
          <!-- banner -->
          <div class="head">
            <slider class="slider" interval="3000" auto-play="true">
              <div class="frame" v-for="img in imageList">
                <image class="image" resize="cover" :src="img.src"></image>
              </div>
            </slider>
          </div>

          <!-- 图标 -->
          <div class="body">
            <div class="logo" v-for="item in lists" @click="muxiclick(item)">
                <image style="width: 120px;height: 120px;" :src="item.icon"></image>
                <text class="text">{{item.name}}</text>
            </div>
          </div>
          
          <div class="body">
            <div class="logo" v-for="item in list2" @click="muxiclick(item)">
                  <image style="width: 120px;height: 120px;" :src="item.icon"></image>
                  <text class="text">{{item.name}}</text>
            </div>
          </div>

        </div>
      </div> 
  </osc-navpage>
</template>

<script>
import route from 'router/page'
import mixins from 'mixins'

const storage = weex.requireModule('storage')
const modal = weex.requireModule('modal')
const stream = weex.requireModule('stream')

export default {
  mixins: [mixins],
  data: {
    lists: [
      {name : '原料管理', icon : 'https://olwr1lamu.qnssl.com/%E4%BE%9B%E5%BA%94%E5%95%86.png', page : 'goods'},
      {name : '库存管理', icon : 'https://olwr1lamu.qnssl.com/%E4%BE%9B%E5%BA%94%E9%93%BE.png', page: 'stockInfo'},
      {name : '采购单', icon : 'https://olwr1lamu.qnssl.com/%E4%BE%9B%E5%BA%94%E5%95%86.png', page: 'purchaseInfo'},
      {name : '配送单', icon : 'https://olwr1lamu.qnssl.com/%E6%88%91%E7%9A%84%E4%BE%9B%E5%BA%94.png', page: 'transferInfo'}
    ],
    list2 : [
      {name : '入库单', icon : 'https://olwr1lamu.qnssl.com/%E4%BB%93%E5%BA%93.png', page: 'storageInfo'}
    ],
    imageList: [
      { src: 'https://olwr1lamu.qnssl.com/banner-%E5%BA%97%E9%93%BA%E4%B8%BB%E9%A1%B5%E9%BB%98%E8%AE%A4.jpg'},
      { src: 'https://olwr1lamu.qnssl.com/01.jpg'}, 
      {
        src: 'https://olwr1lamu.qnssl.com/03.jpg'
      }
    ]
  },
  methods: {
    muxiclick(item) {
      // 跳转到goods页面
      if ('goods' == item.page) {
        this.router.push({
            page: this.routerPage.goods
        })
      }
      if ('purchaseInfo' == item.page) {
        this.router.push({
            page: this.routerPage.purchaseInfo
        })
      }  
      if ('stockInfo' == item.page) {
        this.router.push({
            page: this.routerPage.stockInfo
        })
      } 
      if ('transferInfo' == item.page) {
        storage.getItem('power', event => {

          if ("0" == event.data) {
            modal.alert({
                message: '门店没有权限操作配送单',
                duration: 0.3
            }, callback => {})
          } else{
            this.router.push({
                page: this.routerPage.transferInfo
            })
          }
        })
      } 
      if ('storageInfo' == item.page) {
        this.router.push({
            page: this.routerPage.storageInfo
        })
      }   
    }
  }
}
</script>